import Taro, { Component } from '@tarojs/taro'
import {View, Input, Button, Picker} from '@tarojs/components'
import { AtList, AtListItem } from 'taro-ui'
import {getContractList} from './service'
import moment from 'moment'

export default class contract extends Component {

  config = {
    navigationBarTitleText: '合同查看'
  };

  constructor (props) {
    super(props);
    this.state = {
      contractList: []
    }
  }

  componentDidMount () {
    getContractList().then(res => {
      this.setState({contractList: res});
    })
  }

  openContract = (url) => {
    window.open(url)
  };

  render () {
    const { contractList } = this.state;
    return (
      <View className='fontSize' style='margin-top: 20pt'>
        <AtList>
          {
            contractList.map((item,index) => {
              return <AtListItem title={'合同'} onClick={() => this.openContract(item.beginContractUrl)} arrow='right'
                                 note={item.contractBeginDate && moment(item.contractBeginDate).format('YYYY-MM-DD')} />
            })
          }
        </AtList>
      </View>
    )
  }
}
